package byggeTegning.husGeometri;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;

import javax.media.j3d.Group;
import javax.vecmath.Color3f;

import byggeTegning.geometry.Point3D;


// ***************************************************************************
// *** CLASS: Peis
// ***************************************************************************
public class Peis extends Block
{ 
  public Peis
  (String ident,Point3D p0,double width,double height,double depth)
  { super(ident,p0,width,height,depth);
  }
    
  
  // ***************************************************************************
  // *** METHOD: getModel3D -- TEMP !!!
  // ***************************************************************************
  public /*abstract*/ Group getModel3D(Color3f c)
  { 
    return(null);
  }  

  public void drawProjection(int direction,Graphics2D g,Point2D.Double origo2D,double scale,Color c)
  { Rectangle2D.Double r=projection(direction,origo2D,scale);
    switch(direction)
    {
      case NORTH: tegnPeisFasade(g,r,scale,c); break;
      case SOUTH: tegnPeisFasade(g,r,scale,c); break;
      case EAST: tegnPeisFasade(g,r,scale,c); break;
      case WEST: tegnPeisFasade(g,r,scale,c); break;
//      case ABOVE: drawProjectionAbove(g,r,scale,c); break;
//      case BELOW: drawProjectionBelow(g,r,scale,c); break;
//      case VCUT: drawVerticalCut(g,r,scale,c); break;
      case HCUT: drawHorisontalCut(g,r,scale,c); break;
      default: super.drawProjection(direction,g,origo2D,scale,c);
    }  
  }
      
  private void drawHorisontalCut(Graphics2D g,Rectangle2D.Double r,double scale,Color c)
  { float xp=(float)(r.x+r.width);
    float yp=(float)(r.y+0.6*scale);
    
    yp=yp+(float)(0.05*scale);
    
    draw(g,r); // Omrisset
    
    // Vanger
    GeneralPath vange1=new GeneralPath();
    GeneralPath vange2=new GeneralPath();
    GeneralPath innsats=new GeneralPath();
    float d120=(float)(1.20*scale);
    float d60=(float)(0.60*scale);
    float d10=(float)(0.10*scale);
    float d16=(float)(0.16*scale);
    float d36=(float)(0.36*scale);
    float d44=(float)(0.44*scale);
    float d63=(float)(0.63*scale);
     
    float h1=d36+d10;
    float b1=(d120-d63)/2;
    vange1.moveTo(xp,yp-d60);
    vange1.lineTo(xp-h1,yp-d60);
    vange1.lineTo(xp-h1,yp-d60+b1);
    vange1.lineTo(xp-h1+d10,yp-d60+b1);
    vange1.lineTo(xp-h1+d10,yp-d60+d10);
    vange1.lineTo(xp,yp-d60+d10);
    vange1.lineTo(xp,yp-d60);
    fill(g,vange1,c);
    draw(g,vange1);

    vange2.moveTo(xp,yp+d60);
    vange2.lineTo(xp-h1,yp+d60);
    vange2.lineTo(xp-h1,yp+d60-b1);
    vange2.lineTo(xp-h1+d10,yp+d60-b1);
    vange2.lineTo(xp-h1+d10,yp+d60-d10);
    vange2.lineTo(xp,yp+d60-d10);
    vange2.lineTo(xp,yp+d60);
    fill(g,vange2,c);
    draw(g,vange2);

    // Innsats
    innsats.moveTo(xp-d10,        yp-d44/2);
    innsats.lineTo(xp-d10-d36,    yp-d63/2);
    innsats.lineTo(xp-d10-d36,    yp+d63/2);
    innsats.lineTo(xp-d10-d36,    yp-d63/2);
    innsats.lineTo(xp-d10-d36-d16,yp-d44/2);
    innsats.lineTo(xp-d10-d36-d16,yp+d44/2);
    innsats.lineTo(xp-d10-d36,    yp+d63/2);
    innsats.lineTo(xp-d10,        yp+d44/2);
    innsats.lineTo(xp-d10,        yp-d44/2);
    draw(g,innsats);
  }

  private void tegnPeisFasade
  (Graphics2D g,Rectangle2D.Double r,double scale,Color c)
  {
  }

}
